package com.chemical.search.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 *@className:UserLevel.java
 *@classDescription:
 *@author:MChen
 *@createTime:2012-4-19
 */
@Entity
@Table(name = "user_group")
public class UserGroup {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer group_id; 	// 主键id
	@Column(name = "group_name", nullable = false)
	private String group_name;  // 用户组名称
	@Column(name = "group_desc", nullable = false)
	private String group_desc;   //  用户组描述
	@ManyToMany
	@JoinTable(name="group_function",inverseJoinColumns={@JoinColumn(name="function_id")},joinColumns={@JoinColumn(name="group_id")})
	//Fecth策略定义
	@Fetch(FetchMode.SUBSELECT)
	//集合中对象id的缓存
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<Menu> menus=new HashSet<Menu>(0);
	
	public Integer getGroup_id() {
		return group_id;
	}
	public void setGroup_id(Integer groupId) {
		group_id = groupId;
	}
	public String getGroup_name() {
		return group_name;
	}
	public void setGroup_name(String groupName) {
		group_name = groupName;
	}
	public String getGroup_desc() {
		return group_desc;
	}
	public void setGroup_desc(String groupDesc) {
		group_desc = groupDesc;
	}
	public Set<Menu> getMenus() {
		return menus;
	}
	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}
	@Override
	public String toString() {
		return "UserGroup [group_desc=" + group_desc + ", group_id=" + group_id
				+ ", group_name=" + group_name + ", menus=" + menus + "]";
	}
}
